package com.briup.ch09;

import java.util.Scanner;

/**
 * @Author briup-adam
 * @Date 2023/10/18 上午8:36
 * @Description
 **/

public class ThrowTest {
    public static void main(String[] args) throws Exception {
        try{
            System.out.println(10/0);
        }
        catch (RuntimeException e){
            e.printStackTrace();
        }

        finally {
            System.out.println("回家");
        }

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String name = sc.next();
        if (!name.equals("root")){
            throw  new Exception("用户名不存在");
//            throw  new RuntimeException("用户名不存在");
        }
        System.out.println("请输入密码：");
        String password = sc.next();
        if (!password.equals("briup"))
//            throw  new RuntimeException("密码错误");
            throw  new Exception("密码错误");
    }
}
